//using System;
//using System.Threading;
//using System.Collections;
//using DCRF.Common.Kernel.Helper;
//using DCRF.Common.Kernel.Core;
//using DCRF.Common;
//using DCRF.Common.Helper;
//using DCRF.Common.Core;
//using DCRF.Common.Primitive;
//using System.Reflection;
//using DCRF.Common.Interface;
//using DCRF.Common.DBC;
//using System.Collections.Generic;

//namespace DCRF.Common.Kernel.Core
//{
//    /// <summary>
//    /// Keeps a local repository based on a folder on local drive and looks into that folder to find components
//    /// </summary>
//    public class LocalBlockBroker: MarshalByRefObject, IBlockBroker
//    {
//        private Repository repository = new Repository();
//        private Loader loader = new Loader();
//        private IBlockBroker failover = null;

//        public LocalBlockBroker()
//        {
//        }

//        /// <summary>
//        /// Another broker to use when this broker cannot find required data to load a block
//        /// </summary>
//        public IBlockBroker FailoverBroker
//        {
//            get
//            {
//                return failover;
//            }
//            set
//            {
//                failover = value;
//            }
//        }

//        /// <summary>
//        /// Loads a block specified by given ID from local folder.
//        /// </summary>
//        /// <param name="handle"></param>
//        /// <returns>A reference to instance of loaded block or null if required file not found</returns>
//        public IBlock LoadBlock(CID handle, params object[] args)
//        {
//            //first find a Block descriptor for a Block with this specs
//            BlockDescriptor Block = repository.FindBlock(handle);

//            if (Block == null)
//            {
//                if (failover != null)
//                {
//                    return failover.LoadBlock(handle);
//                }

//                throw new Exception("Cannot find the specified Block.");
//            }

//            if (Block.Enabled == false)
//            {
//                throw new Exception("The required Block is disabled.");
//            }

//            //why call this?
//            repository.Load();

//            return loader.LoadBlock(Block, args);
//        }

//        /// <summary>
//        /// Initialize the broker
//        /// </summary>
//        /// <param name="options">Options for this broker (path to assemblies folder)</param>
//        public void SetupBroker(IBlockBrokerOptions options)
//        {
//            Check.Ensure(options != null);
//            Check.Ensure(options is RepositoryOptions);

//            repository.Folder = (options as RepositoryOptions).Folder;
//            loader.SetGeneralLibrariesPath((options as RepositoryOptions).GeneralLibrariesPath);
//        }

//        /// <summary>
//        /// Returns a list of block IDs in this broker
//        /// </summary>
//        public List<CID> Blocks
//        {
//            get
//            {
//                List<CID> result = new List<CID>();
//                foreach (BlockDescriptor bd in repository.Blocks)
//                {
//                    result.Add(bd.ID);
//                }

//                return result;
//            }
//        }

//        /// <summary>
//        /// Release resources associated to this block
//        /// </summary>
//        /// <param name="comp"></param>
//        public void DisposeBlock(IBlock comp)
//        {
//            Check.Ensure(comp != null);

//            comp.Dispose();

//            if (failover != null)
//            {
//                failover.DisposeBlock(comp);
//            }
//        }
//    }
//}
